package com.csun.dsms.utils;

import com.google.common.base.Preconditions;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2020-11-02 09:37
 * @Description:
 */
public class RedisKeyUtil {

    private static final String DEVICE_GATEWAY = "slm:device:gateway";
    private static final String DEVICE_LOCK = "slm:device:lock";
    private static final String GATEWAY_TASK = "slm:device:gateway:task";

    public static final String GATEWAY_ONLINE = "slm:device:gateway:online";

    public static String getGatewayKey(String deviceNo) {

        Preconditions.checkArgument(PublicUtil.isNotEmpty(deviceNo),
                "设备编号不能为空");

        return DEVICE_GATEWAY + ":" + deviceNo;
    }

    public static String getLockKey(String deviceNo) {

        Preconditions.checkArgument(PublicUtil.isNotEmpty(deviceNo),
                "设备编号不能为空");

        return DEVICE_LOCK + ":" + deviceNo;
    }

    public static String getGatewayOnline(String deviceNo) {

        Preconditions.checkArgument(PublicUtil.isNotEmpty(deviceNo), "设备编号不能为空");

        return GATEWAY_ONLINE + ":" + deviceNo;
    }

    public static String getGatewayTask(String messageId) {

        Preconditions.checkArgument(PublicUtil.isNotEmpty(messageId), "任务编号不能为空");

        return GATEWAY_TASK + ":" + messageId;
    }
}
